import { OperationGuideType } from './operation-guide-type';
import { IGuideItemOptions } from './guide-item';
import { IScrollGuideItemListOptions } from './scroll-guide-item-list';
import { ANCHOR } from '../../../gui/control/abstract-base';


/**
 * 操作指导参数信息抽象类
 * @param types 包含的操作类型
 */
abstract class AbstractGuideItems {

    /**
     * 成员参数对象
     */
    public readonly items: IGuideItemOptions[] = [];

    constructor(types: OperationGuideType[]) {
        this.initializeItems(types);
    }

    private initializeItems(types: OperationGuideType[]): void {
        for (const typ of types) {
            switch (typ) {
                case OperationGuideType.move:
                    this.items.push(...this.getItemOptions(this.moveImagesAndContents));
                    break;
                case OperationGuideType.orientate:
                    this.items.push(...this.getItemOptions(this.orientateImagesAndContents));
                    break;
                case OperationGuideType.pan:
                    this.items.push(...this.getItemOptions(this.panImagesAndContents));
                    break;
                case OperationGuideType.zoom:
                    this.items.push(...this.getItemOptions(this.zoomImagesAndContents));
                    break;
                case OperationGuideType.click:
                    this.items.push(...this.getItemOptions(this.clickImagesAndContents));
                    break;
                case OperationGuideType.drag:
                    this.items.push(...this.getItemOptions(this.dragImagesAndContents));
                    break;
                case OperationGuideType.press:
                    this.items.push(...this.getItemOptions(this.pressImagesAndContents));
                    break;
            }
        }
    }

    /**
     * 滚动容器参数对象
     */
    public get scrollOptions(): IScrollGuideItemListOptions {
        return {
            anchor: ANCHOR.RIGHT_CENTER,
            unitWidth: 0.6,
            unitHeight: 0.075,
            rowLength: 1,
            columnLength: 4,
            backgroundAlpha: 0.6,
        };
    }

    /**
     * 移动操作的图标及内容
     */
    protected abstract get moveImagesAndContents(): Array<[string, string]>;

    /**
     * 旋转视角操作的图标及内容
     */
    protected abstract get orientateImagesAndContents(): Array<[string, string]>;

    /**
     * 点击操作的图标及内容
     */
    protected abstract get clickImagesAndContents(): Array<[string, string]>;

    /**
     * 拖动操作的图标及内容
     */
    protected abstract get dragImagesAndContents(): Array<[string, string]>;

    /**
     * 按住操作的图标及内容
     */
    protected abstract get pressImagesAndContents(): Array<[string, string]>;

    /**
     * 缩放操作的图标及内容
     */
    protected abstract get zoomImagesAndContents(): Array<[string, string]>;

    /**
     * 平移操作的图标及内容
     */
    protected abstract get panImagesAndContents(): Array<[string, string]>;

    private getItemOptions(imagesAndContens: Array<[string, string]>): IGuideItemOptions[] {
        const res: IGuideItemOptions[] = [];
        for (const iac of imagesAndContens) {
            res.push(this.createItem(iac[0], iac[1]));
        }
        return res;
    }

    private createItem(imageUrl: string, content: string): IGuideItemOptions {
        const ops = this.itemCommonOptions;
        ops.imageUrl = imageUrl;
        ops.content = content;
        return ops;
    }

    /**
     * 成员参数对象通用部分
     */
    protected get itemCommonOptions(): IGuideItemOptions {
        return {
            imageWidth: 60,
            imageHeight: 60,
            fontSize: 27,
            contentHeight: 60,
        };
    }

}


export { AbstractGuideItems };